﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Query>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Create
</asp:Content>

<asp:Content ID="javascript" ContentPlaceHolderID="Javascript" runat="server">
    
    <script type="text/javascript">
        $(document).ready(function() {
            //$("#EnquiryDate").datepicker({ dateFormat: 'dd/mm/yy'});
            var myDate = new Date();
            var prettyDate = (myDate.getDate() + '/' + (myDate.getMonth() + 1) + '/' + myDate.getFullYear());
            //alert(prettyDate)

            $(".date").val(prettyDate);
            $(".date").dateinput({ format: 'dd/mm/yyyy' });
            //$(".date").dateinput({ format: 'dd/mm/yy', value: prettyDate })

            $("ul.tabs").tabs("div.panes > div", { event: 'mouseover', initialIndex: 1 });

            //hide some form items
            //$("#product").hide();
            //$("#typeDrillDown").hide();

            //if ($("#Status").value != "Complete") {
            //    $("#StatusChildren").hide();
            //}

            if ($("#PaymentType").value != "None") {
                $("#PaymentTypeChildren").hide();
            }
            if ($("#Source").value != "Retailer") {
                $("#retailerDiv").hide();
            }

            if ($("#productid1").val() != "OUST" || $("#CategoryId").val() != "1" || $("#CategoryId").val() != "1" && $("#Query_QueryType").val() == "1") {
                $("#WmDiv").hide();
            }

            //alert("Start");
            /*$("#CategoryId").change(function() {
            //alert("change");
            var catDrillDownsUrl = '<%= Url.Action("CategoryDrillDowns", "Enquiry", new {typeID = 1, id = 999}) %>';
            var url = catDrillDownsUrl.replace("999", $(this).val());
            //alert(url);
            $("#product").show();
            $("#product").load(url, productDrillDownLoaded);


                // alert($(this).val());
            if ($(this).val() == "1" || $(this).val() == "2") {
            //alert("yes");
            $("#WmDiv").show();

                }
            else {
            //alert("no");
            $("#WmDiv").hide();
            $("#WmManufacturere").val('');
            $("#WmModel").val('');
            }
            });*/
            /*$("#typeId").change(function() {
            //alert("change");
            var catDrillDownsUrl = '<%= Url.Action("CategoryDrillDowns", "Enquiry", new {typeID = 998, id = 999}) %>';
            var url = catDrillDownsUrl.replace("999", $("#CategoryId").val());
            url = url.replace("998", $(this).val());
            //alert(url);
            $("#typeDrillDown").show();
            $("#typeDrillDown").load(url, typeDrillDownLoaded);


            });*/
            //alert("End");

            /*$("#Status").change(function() {
            if ((this).value == "Complete") {
            $("#StatusChildren").show();
            }
            else {
            $("#StatusChildren").hide();
            }
            });*/

            $("#Source").change(function() {
                if ((this).value != "Retailer") {
                    $("#retailerDiv").hide();
                }
                else {
                    $("#retailerDiv").show();
                    $("#Retailer").val('');
                }
            });

            $("#PaymentType").change(function() {
                if ((this).value == "None") {
                    $("#PaymentTypeChildren").hide();
                }
                else {
                    $("#PaymentTypeChildren").show();
                    $("#Amount").val('');
                }
            });

            $("#Query_QuerySelectionId").live("change", function() {
                       
                //alert((this).value);
                
                if ($("#Complaint0").length == 0) {
                    
                //if ((this).value == "196" || (this).value == "219" || (this).value == "375") {

                    if ($("#Query_CategoryId").val() == "1" || $("#Query_CategoryId").val() == "2" || (this).value == "375") {
                    //alert("yes");
                    $("#WmDiv").show();
                }
                else {
                    //alert("no");
                    $("#WmDiv").hide();
                   // $("#WmModel").val('');
                }
            }
            });
            //            $("#Source").change(function() {
            //                if ((this).value != "Retailer") {
            //                    $("#retailerDiv").hide();
            //                }
            //                else {
            //                    $("#retailerDiv").show();
            //                    $("#Retailer").val('');
            //                }
            //            });


            //validation
            //            $("#EnquiryForm").validate({
            //                rules: {
            //                    txtTelNumber: {
            //                        required: true,
            //                        phoneUS: true
            //                    }
            //                }
            //            });
            //            jQuery.validator.messages.required = ""; 

        });

        /*var productDrillDownLoaded = function() {
            //alert("DrillDownLoaded");
            //alert($("#DrillDown1").length);
            if ($("#DrillDown1").length == 1) {
                $("#type").show();
                $("#typeId").focus();
            }
            else {
                $("#DropDownId").focus();
                $("#DropDownId").change(function() {
                    //alert("DrillDownChanges");
                    var prodDrillDownUrl = '<%= Url.Action("ChildDrillDowns", "Enquiry", new {id = 999}) %>';
                    var url = prodDrillDownUrl.replace("999", $(this).val());
                    //alert(url);
                    $("#product").show();
                    $("#product").load(url, productDrillDownLoaded);

                    //check for specfic product to display wmDiv
                    //catid = $("CategoryId").value;
                    //alert(catid);
                    if ($("#productid1").val() == "OUST" || $("#CategoryId").val() == "1" || $("#CategoryId").val() == "2") {
                        //alert("here: " + $("#productid1").val() == "OUST" + "," + $("#CategoryId").val() == "1" + "," + $("#CategoryId").val() == "2");
                        $("#WmDiv").show();
                    }
                    else {
                        //alert("dd hide, " + $("#productid1").val() + "," + $("#CategoryId").val() + "," + $("#CategoryId").val())
                        $("#WmDiv").hide();
                        $("#WmManufacturere").val('');
                        $("#WmModel").val('');
                    }
                });
            }


        };*/

/*
        var typeDrillDownLoaded = function() {
            //alert("DrillDownLoaded");
            $("#DropDownId").focus();
            $("#DropDownId").change(function() {
                //alert("DrillDownChanges");
                var prodDrillDownUrl = '<%= Url.Action("ChildDrillDowns", "Enquiry", new {id = 999}) %>';
                var url = prodDrillDownUrl.replace("999", $(this).val());
                //alert(url);
                $("#typeDrillDown").show();
                $("#typeDrillDown").load(url, typeDrillDownLoaded);

                
            });
        };*/
    </script>
</asp:Content>

<asp:Content ID="ContentHeader" ContentPlaceHolderID="ContentHeader" runat="server">
Create an enquiry
</asp:Content>  

<asp:Content ID="ContentSubNav" ContentPlaceHolderID="ContentSubNav" runat="server">
    <li class="selected"><%= Html.ActionLink("Create Enquiry", "Create", "Enquiry")%></li>
    <li class=""><%= Html.ActionLink("Open Enquiries", "Index", "Enquiry")%></li>
    <li class=""><%= Html.ActionLink("Completed Enquiries", "Completed", "Enquiry")%></li>
    <%--<li class=""><%= Html.ActionLink("Pending Compensation", "Pending", "Enquiry")%></li>--%>
    <li class=""><%= Html.ActionLink("Approved Compensation", "Approved", "Enquiry")%></li>
    <li class=""><%= Html.ActionLink("Declined Compensation", "Declined", "Enquiry")%></li>    
    <li class=""><%= Html.ActionLink("Complaints Alert", "ComplaintsAlert", "Enquiry")%></li>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%--<% Html.EnableClientValidation(); %>--%>
<p>Please enter the query....</p>


    <%= Html.ValidationSummary(true, "There were some errors with your form. Please correct and try again") %>
    <% using (Html.BeginForm("Create", "Enquiry", FormMethod.Post, new {id = "EnquiryForm",  @class = "faux_form" })){%> 
    
	    <ul class="tabs">
		    <li><a href="#tabs-1">Contact Details</a></li>
		    <li><a href="#tabs-2">Query Details</a></li>
		    <li><a href="#tabs-3">Resolution</a></li>
		</ul>
	    <div class="panes">
	        <div class="pane">
	            <%--USER INFO--%>
                <div class="formRegion">
                    <div>
                        <%= Html.LabelFor(m => m.FirstName)%>
                        <%= Html.TextBoxFor(m => m.FirstName, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.FirstName) %>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.LastName)%>
                        <%= Html.TextBoxFor(m => m.LastName, new { @class = "text" })%>
                        <%= Html.ValidationMessageFor(m => m.LastName)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.Email)%>
                        <%= Html.TextBoxFor(m => m.Email, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.Email)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.Telephone)%>
                        <%= Html.TextBoxFor(m => m.Telephone, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.Telephone)%>
                    </div>
                </div>
                <div class="formRegion">
                    <div>
                        <%= Html.LabelFor(m => m.AddressLine1)%>
                        <%= Html.TextBoxFor(m => m.AddressLine1, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.AddressLine1)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.AddressLine2)%>
                        <%= Html.TextBoxFor(m => m.AddressLine2, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.AddressLine2)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.Town)%>
                        <%= Html.TextBoxFor(m => m.Town, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.Town)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.County)%>
                        <%= Html.TextBoxFor(m => m.County, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.County)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.PostCode)%>
                        <%= Html.TextBoxFor(m => m.PostCode, new { @class = "text" })%>
                        <%= Html.ValidationMessageFor(m => m.PostCode)%>
                    </div>
                    <div>
                        <%= Html.LabelFor(m => m.Country)%>
                        <%= Html.TextBoxFor(m => m.Country, new {@class = "text"}) %>
                        <%= Html.ValidationMessageFor(m => m.Country)%>
                    </div>
                </div>
            </div><%--<<< tabs-1 end--%>
            <div class="pane">
                <div class="formRegion">
                    <div>
                    <%--SOURCES--%>
                        <%= Html.LabelFor(m => m.Source)%>
                        <%= Html.DropDownListFor(m => m.Source,
                                SelectListHelpers.GetSelectListFromEnum<Query.QuerySource>(),
                                "Choose an option",
                                new { @class = "text required" })%>
                        <%= Html.ValidationMessageFor(m => m.SourceId)%>
                    </div>
                    <div id="retailerDiv">
                    <%--Retailers--%>
                        <%= Html.LabelFor(m => m.Retailer)%>
                        <%= Html.DropDownListFor(m => m.Retailer,
                                SelectListHelpers.GetSelectListFromEnum<Query.Retailers>(),
                                "Choose an option",
                                new { @class = "text required" })%>
                        <%= Html.ValidationMessageFor(m => m.Retailer)%>
                    </div>
                    <%--DATE--%>
                    <div>
                        <%= Html.LabelFor(m => m.EnquiryDate)%>
                        <%= Html.TextBoxFor(m => m.EnquiryDate, new { @class = "text date required" })%>
                        <%= Html.ValidationMessageFor(m => m.EnquiryDate)%>
                    </div>
                                
                    <%--PRIORITY--%>
                    <div>
                        <%= Html.LabelFor(m => m.Priority)%>
                        <%= Html.DropDownListFor(m => m.Priority, new[]{
                            new SelectListItem{Text = "1", Value = "1"},
                            new SelectListItem{Text = "2",Value = "2"},
                            new SelectListItem{Text = "3",Value = "3"}
                        }, "Set the priority", new { @class = "text required" }  
                         ) %>
                        <%= Html.ValidationMessageFor(m => m.Priority)%>
                    </div>
                </div>     
	            <div id="drilldowns" class="formRegion">
	                <%--<% Html.RenderAction("DrillDown", new { }); %>--%>
	                <% Html.RenderPartial("Partial/DrillDown", new SpotlessWeb.Models.QueryDrillDownViewModel() { AllowEdit = true, Query = new Query(), Categories = ViewData.GetCategories().ToArray(), DrillDowns = new DrillDown[0] }); %>
                </div>
                
                <div>
                    <%= Html.LabelFor(m => m.BatchCode)%>
                    <%= Html.TextBoxFor(m => m.BatchCode, new {@class = "text"}) %>
                    <%= Html.ValidationMessageFor(m => m.BatchCode)%>
                </div>
                
                <div id="WmDiv" class="formRegion">
                    <div>
                    <%--WmManufacturere--%>
                        <%= Html.LabelFor(m => m.WmManufacturere)%>
                        <%= Html.DropDownListFor(m => m.WmManufacturere,
                                SelectListHelpers.GetSelectListFromEnum<Query.WmManufacturers>(),
                                "Choose an option",
                                new { @class = "text" })%>
                        <%= Html.ValidationMessageFor(m => m.WmManufacturere)%>
                    </div>
                    <%--DATE--%>
                    <div>
                        <%= Html.LabelFor(m => m.WmModel)%>
                        <%= Html.TextBoxFor(m => m.WmModel, new { @class = "" })%>
                        <%= Html.ValidationMessageFor(m => m.WmModel)%>
                    </div>
                </div>
               
            </div><%--<<<tans-2 end--%>
            <div class="pane">
                 <div class="formRegion">
                    <div id="" class="childrenHolder">
                        <div>
                            <%--METHOD--%>
                            <%= Html.LabelFor(m => m.Method)%>
                            <%= Html.DropDownListFor(m => m.Method, SelectListHelpers.GetSelectListFromEnum<Query.Methods>(), "Set the Method", new { @class = "text required" })%>
                            <%= Html.ValidationMessageFor(m => m.Method)%>
                        </div>
                        <div>
                            <%--PAYMENT--%>
                            <%= Html.LabelFor(m => m.PaymentType)%>
                            <%= Html.DropDownListFor(m => m.PaymentType, SelectListHelpers.GetSelectListFromEnum<Query.PaymentTypes>(), null, new { @class = "text required" })%>
                            
                            <%= Html.ValidationMessageFor(m => m.PaymentType)%>
                        </div>
                        <div id="PaymentTypeChildren" class="childrenHolder">
                            <div>
                                <%--AMOUNT--%>
                                <%= Html.LabelFor(m => m.Amount)%>
                                <%= Html.TextBoxFor(m => m.Amount, new { @class = "text" })%>
                                <%= Html.ValidationMessageFor(m => m.Amount)%>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="formRegion">
                    <div>
                        <%--STATUS--%>
                        <%= Html.LabelFor(m => m.Status)%>
                        <%= Html.DropDownListFor(m => m.Status, SelectListHelpers.GetSelectListFromEnum<Query.QueryStatus>(), null, new { @class = "text required" })%>
                        <%= Html.ValidationMessageFor(m => m.Status)%>
                    </div>
                </div>
            </div><%--<<<pane3--%>
        </div><%--<<<tabs--%>
        <div>
            <%--FREETEXT--%>
            <%= Html.Label("FreeTextArea")%>
            <%= Html.TextArea("FreeTextArea", null, new { @class = "textarea", cols = 10, rows = 4 })%>
        </div>
        <div style="border:0;">
            <input type="submit" class="submit" value="ENTER" />
        </div>
        <% } %>

</asp:Content>
